/*
 * Copyright (c) 2023 Cshoo Org. All Rights Reserved.
 */

package org.tattoo.workflow.domain.repository;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.Transactional;
import org.tattoo.workflow.domain.po.ProcurementOrder;

/**
 * @author 杨翼
 * @since 1.0
 */
public interface IProcurementOrderRepository extends CrudRepository<ProcurementOrder, Long> {
    /**
     * 修改采购订单
     * 这里只修改流程实例id，订单名称，订单描述，最后更新人，最后更新时间
     *
     * @param procurementOrder 采购订单po对象
     */
    @Query("update ProcurementOrder procurementOrder set procurementOrder.processInstanceId = :#{#procurementOrder.processInstanceId}, procurementOrder.name = :#{#procurementOrder.name}, procurementOrder.description = :#{#procurementOrder.description}, procurementOrder.lastUpdatedBy = :#{#procurementOrder.lastUpdatedBy}, procurementOrder.lastUpdateTime = :#{#procurementOrder.lastUpdateTime} where procurementOrder.id = :#{#procurementOrder.id}")
    @Modifying
    @Transactional(rollbackFor = Exception.class)
    void updateProcurementOrder(ProcurementOrder procurementOrder);
}
